#pragma once

#include "Defines.h"
#include <string>
#include <map>
#include <SFML/Graphics.hpp>


struct Image 
{
	Image(): refCount(0) {}
	sf::Image image;
	int refCount;
};

class ResourceSystem
{
	typedef std::map<uint16, Image*> ImageMap;		//TODO: make this more efficient if possible! use list?
	typedef std::map<std::string, uint16> FilenameMap;
public:
	ResourceSystem();
	~ResourceSystem();
	static sf::Image* GetImage(const std::string& filename, const sf::Color& alpha = sf::Color(0,0,0), bool allowRefCount = true);
	static uint16 GetId(const std::string& filename);

	static void FreeImage(const std::string& filename);		
	static void FreeImage(uint16 filenameId);

private:
	static std::string GetName(uint16 id);
	static bool FreeImage(const ImageMap::iterator& i);


private:

	static FilenameMap filenames;
	static ImageMap images;
	static uint32 m_count;


};
